package com.slkj.shilixiaoyuanapp.ui.parent.tool.exercise;

import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.api.InjectParam;
import com.slkj.shilixiaoyuanapp.R;
import com.slkj.shilixiaoyuanapp.base.ActivityInfo;
import com.slkj.shilixiaoyuanapp.base.BaseActivity;
import com.slkj.shilixiaoyuanapp.data.UserRequest;
import com.slkj.shilixiaoyuanapp.entity.parent.ExerciseDetailEntity;
import com.slkj.shilixiaoyuanapp.net.HttpHeper;
import com.slkj.shilixiaoyuanapp.net.callback.CommonCallBack;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

@ActivityInfo(layout = R.layout.activity_history_detail,title = "锻炼详情")
public class HistoryDetailActivity extends BaseActivity {
//    @BindView(R.id.rv_exercisedetail)
//    RecyclerView rv_exercisedetail;
    @BindView(R.id.tv_student_name)
    TextView tv_student_name;
    @BindView(R.id.tv_exercise_name)
    TextView tv_exercise_name;
    @BindView(R.id.tv_time)
    TextView tv_time;
    private BaseQuickAdapter adapter;
    private List<String> datas=new ArrayList<>();
    @InjectParam
    int id;
    int stuId;
    int classId;
    @Override
    protected void init() {
        HistoryDetailActivity__JumpCenter.bind(this);
        getData();
//        datas.add("羽毛球");
//        datas.add("跑步");
//        adapter=new BaseQuickAdapter<String,BaseViewHolder>(R.layout.item_exercise_detail,datas) {
//            @Override
//            protected void convert(BaseViewHolder helper, String item) {
//                helper.setText(R.id.tv_exercise_pro,item);
//                helper.setText(R.id.tv_exercise_long,"0.5");
//                helper.setText(R.id.tv_exercise_num,"锻炼明细"+(helper.getAdapterPosition()+1));
//            }
//        };
//        rv_exercisedetail.setLayoutManager(new LinearLayoutManager(this));
//        rv_exercisedetail.setAdapter(adapter);
    }

    private void getData() {
        for (int i = 0; i<UserRequest.getInstance().getUser().getStudents().size(); i++){
            if (UserRequest.getInstance().getUser().getStudents().get(i).getIsSelect()==1){
                stuId= UserRequest.getInstance().getUser().getStudents().get(i).getId();
                classId= UserRequest.getInstance().getUser().getStudents().get(i).getClassId();
            }
        }
        HttpHeper.get().parentService()
                .getExerciseDetail(stuId,classId,id)
                .compose(bindToLifecycle())
                .compose(getThread())
                .subscribe(new CommonCallBack<ExerciseDetailEntity>(HistoryDetailActivity.this) {
                    @Override
                    public void onCallBackSuccess(ExerciseDetailEntity data) {
                        tv_student_name.setText(data.getName());
                        tv_exercise_name.setText(data.getTypeName());
                        tv_time.setText(data.getHours()+"");
                    }
                });
    }

}
